package hk.com.fgoproduction.getdroplets.Activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import hk.com.fgoproduction.getdroplets.Lib.Common.ToolInstance.CheckConnection
import org.jetbrains.anko.*

class ReconnectActivity : Activity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initView()
    }

    private fun initView() {
        val view = verticalLayout {
            textView("No Connectivity!").lparams(width = wrapContent, height = wrapContent)
            val btn = button("Retry Connection!").lparams(width = wrapContent, height = wrapContent)

            btn.onClick {
                if (CheckConnection.isOnline(this@ReconnectActivity)) {
                    val intent = Intent(this@ReconnectActivity, MainActivity::class.java)
                    setResult(RESULT_OK)
                    finish()
                } else {
                    toast("Check your connection and try again!")
                }
            }
        }
    }


}